﻿// code02060100.cpp : 自定义数据结构
// 自定义Sales_data类

#include <iostream>
#include "Sales_data.h"
using namespace std;
int main()
{
    Sales_data book1, book2;
    Sales_data sumBooks;
    double price1, price2;
	cout << "输入ISBN号，数量和单价" << endl;
	cin >> book1.bookNo >> book1.units_sold >> price1;
    if (book1.units_sold == 0)
    {
        cout << "无数据，程序退出" << endl;
        return -1;
    }
    book1.revenue = book1.units_sold * price1;
    cout << "输入ISBN号，数量和单价" << endl;
    cin >> book2.bookNo >> book2.units_sold >> price2;
    if (book2.units_sold == 0)
    {
        cout << "无数据，程序退出" << endl;
        return -1;
    }
    book2.revenue = book2.units_sold * price2;

    if (book1.bookNo==book2.bookNo)
    {
	    
        sumBooks.bookNo = book1.bookNo;
        sumBooks.units_sold = book1.units_sold + book2.units_sold;
        sumBooks.revenue = book1.revenue + book2.revenue;
        cout << sumBooks.bookNo << " " << sumBooks.units_sold << " " << sumBooks.revenue << " " << 1.0*sumBooks.revenue / sumBooks.units_sold << endl;
    }
    else
    {
        cout << "两本书号不一致，无法合计" << endl;
        return -1;
    }
 
    

    
}

